package com.zmj.base;

import java.util.Arrays;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author jinyanan
 * @since 2020/5/27 14:32
 */
@Getter
@AllArgsConstructor
public enum ExceptionEnum {

    /* 成功状态码 */
    SUCCESS(1, "成功"),
    /* 服务器错误 */
    FAIL(0, "失败"),

    FAILT(1, "失败了"),

    ;

    private final int code;

    private final String message;

    public static ExceptionEnum parse(int code) {
        return Arrays.stream(ExceptionEnum.values()).filter(input -> input.getCode() == code).findFirst().orElse(null);
    }
}
